//
//  MyDiagnosisViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/11/10.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "MyDiagnosisViewController.h"
#import "XXPageTabView.h"
#import "XXPageTabItemLable.h"
#import "DiagnosisViewController.h"
#import "ServiceIncomeViewController.h"
@interface MyDiagnosisViewController ()<XXPageTabViewDelegate>
@property (nonatomic, strong) XXPageTabView *pageTabView;
@end

@implementation MyDiagnosisViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.pageTabView];
}

- (XXPageTabView *)pageTabView
{
    if (!_pageTabView) {
        
        DiagnosisViewController *vc1 = [DiagnosisViewController new];
        vc1.index = 0;
        [self addChildViewController:vc1];
        
        DiagnosisViewController *vc2 = [DiagnosisViewController new];
        vc1.index = 1;
        [self addChildViewController:vc2];
        
        ServiceIncomeViewController *vc3 = [ServiceIncomeViewController new];
        [self addChildViewController:vc3];
        
        //支持网易云音乐，今日头条，微博等切换栏效果
        _pageTabView = [[XXPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"待服务",@"已服务",@"服务收入"]];
        _pageTabView.frame = CGRectMake(0, Hn, Wi, Hi-Hn);
        
        _pageTabView.selectedTabIndex = 0;
        _pageTabView.maxNumberOfPageItems = 4;
        _pageTabView.tabSize = CGSizeMake(Wi, 44);
        _pageTabView.tabItemFont = FONT_FOURTEEN;
        
        _pageTabView.unSelectedColor = White(50);
        _pageTabView.selectedColor = COLOR_GREEN;
        
        _pageTabView.tabBackgroundColor = White(250);
        
        //_pageTabView.separatorColor = [[UIColor grayColor] colorWithAlphaComponent:0.4];
        _pageTabView.bodyBounces = NO;
        
        _pageTabView.indicatorWidth = 50;
        _pageTabView.indicatorHeight = 2;
        
        _pageTabView.delegate = self;
        _pageTabView.titleStyle = XXPageTabTitleStyleDefault;
        _pageTabView.indicatorStyle = XXPageTabIndicatorStyleDefault;
        
        UIScrollView *bodyView = [_pageTabView valueForKey:@"bodyView"];
        [bodyView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    }
    return _pageTabView;
}

- (void)pageTabViewDidEndChange
{
    DLog(@"page = %i", (int)self.pageTabView.selectedTabIndex);
}


@end
